<?php

	/**
	 * @see Bike_Js_Base
	 */
	require_once 'Bike/Js/Base.php';
	
	
	abstract class Bike_Js_VarPart extends Bike_Js_Base
	{
        static protected $_partOffset = null;
        static protected $_initObject = False;

        protected $_var;
        protected $_part;
        protected $_accessor;
        
        public function getOmitSettings()
        {
        	return array_merge(parent::getOmitSettings(), array('varPartType'));
        }
        
        public function getPartOffset()
        {
        	$className = get_class($this);
        	$res = '';
        	eval('$res='.$className.'::$_partOffset;');
        	return $res;
        }
        
        public function getInitObject()
        {
        	$className = get_class($this);
        	$res = '';
        	eval('$res='.$className.'::$_initObject;');
        	return $res;
        }

        protected function _setParamsFromArgs($Args)
        {        	$var = array_shift($Args);
        	//$this->setVar($var);
        	$this->setAccessor(array_shift($Args));
        	return $Args;
        }

        public function makeOptions(array $Args=null)
		{
			$Args = $this->_setParamsFromArgs($Args);
			return $this->_makeOptions($Args);
		}

        protected function _makeOptions(array $Args=null)
		{
			$options = array();
			if(sizeof((array) $Args))
			{
				$part = array_shift($Args);
				$argsCount = sizeof($Args);
				if($argsCount)
				{
					$options = $Args;
				}
				$options['part'] = $part;
			}
			return $options;
		}

        public function getPart()
        {        	return $this->_part;
        }

        public function setPart($Part)
        {
        	$this->_part = $Part;
        	return $this;
        }

        public function getAccessor()
        {
        	return $this->_accessor;
        }

        public function setAccessor($Accessor)
        {
        	$this->_accessor = $Accessor;
        	return $this;
        }
        
        public function getVarCaching()
        {
        	return False;
        }

        public function setVar($Var)
        {
        	$this->_var = $Var;
        	return $this;
        }

        public function _var()
        {        	throw new Bike_Js_Exception('var');
        	//return $this->_var;
        }

		public function _toString()
		{			return (is_array($this->getPart()) ? join('.', $this->getPart()) : $this->getPart());
		}
	}
